package com.flw.eslab.service.impl;

import java.io.File;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.flw.eslab.dao.UserInfoDao;
import com.flw.eslab.dto.PageInfo_Dto;
import com.flw.eslab.model.Task;
import com.flw.eslab.model.UserInfo;
import com.flw.eslab.service.UserInfoManager;
@Service("userInfoManager")
public class UserInfoManagerImpl implements UserInfoManager {
	@Resource
	private UserInfoDao userInfoDao;
	
	public UserInfoDao getUserInfoDao() {
		return userInfoDao;
	}

	public void setUserInfoDao(UserInfoDao userInfoDao) {
		this.userInfoDao = userInfoDao;
	}

	@Override
	public boolean add(UserInfo userInfo) {
		if(userInfo.getUser()!=null){
			userInfoDao.save(userInfo);
			return true;
		}
		return false;
	}

	@Override
	public boolean delete(UserInfo userInfo) {
		if(userInfo.getId()!=null&&(userInfoDao.findById(UserInfo.class, userInfo.getId())!=null))
		{
			userInfoDao.deleteById(UserInfo.class, userInfo.getId());
			return true;
		}
		return false;
	}

	@Override
	public boolean modify(UserInfo userInfo) {
		if(userInfo.getId()!=null&&(userInfoDao.findById(UserInfo.class, userInfo.getId())!=null))
		{
			userInfoDao.update(userInfo);
			return true;
		}
		return false;
	}

	@Override
	public File output() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public PageInfo_Dto load(PageInfo_Dto pageInfo_Dto) {
		int pageNow=pageInfo_Dto.getPageNow()==null?1:pageInfo_Dto.getPageNow();
		int pageSize=pageInfo_Dto.getPagesize()==null?5:pageInfo_Dto.getPagesize();	
		return userInfoDao.findByPageInfo(UserInfo.class, pageNow, pageSize, null, null);
	}

}
